<?php

namespace App\Http\Controllers\Car;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\Sundry;
use Illuminate\Http\Request;

class SundryController extends Controller
{
    use ResponseData;
    public function list(Sundry $sundry,Request $request){
        $data = $sundry->query()->get();
        return $this->success($data);
    }
    public function store(Sundry $sundry,Request $request){
        $data = $request->all();
        $sundry->fill($data);
        $sundry->save();
        return $this->success('保存成功');
    }
    public function edit(Sundry $sundry,Request $request){
        $data = $sundry->find($request->id);
        return $this->success($data);
    }
    public function update(Sundry $sundry,Request $request){
        $data = $sundry->find($request->id);
        $data->update($request->all());
        return $this->success('修改成功');
    }
    public function destory(Sundry $sundry,Request $request){
        $data = $sundry->find($request->id);
        $data->delete();
    }
}
